<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class AdminBackEndController extends BackEndController {
    public function __construct() {
        parent::__construct();
        $this->load->helper('admin');
    }

    public function checkRole() {
        if($this->role!=ROLE_ADMIN && $this->role!=ROLE_MOD){
            header('location:'.page_url('dang-nhap'));
        }
        if($this->role==ROLE_MOD) {
            $reservedPage = array(PAGE_SLUG);
            $aSegment = $this->uri->segment_array();
            if(isset($aSegment[2]) && in_array($aSegment[2], $reservedPage)){
                show_404();
            }
        }
    }

    public function renderView($viewName, $data = null) {
        $this->loadView('backend/layout/layout', $viewName, $data);
    }

    public function getAdvertiseUpload($name, $type) {
        $this->load->helper('file');
        $string = read_file(UPLOAD_FOLDER_URL.ADVERTISE_FOLDER_URL.$name);
        $this->output->set_content_type("application/{$type}")->set_output($string);
        $this->output->set_header("HTTP/1.0 200 OK");
        $this->output->set_header("HTTP/1.1 200 OK");
        $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
        $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
        $this->output->set_header("Cache-Control: post-check=0, pre-check=0");
        $this->output->set_header("Pragma: no-cache");
    }
}
?>